package com.jkd.service.impl;

import com.jkd.mapper.StudentMapper;
import com.jkd.model.pojo.Student;
import com.jkd.service.IStudentService;
import com.jkd.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

public class StudentServiceImpl implements IStudentService {
    @Override
    public Student selectByStuNum(String stuNum) {
        SqlSession sqlSession = MyBatisUtil.getSqlSession();
        StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
        Student student = studentMapper.selectByStuNum(stuNum);
        MyBatisUtil.closeSqlSession(sqlSession);
        return student;
    }

    @Override
    public Boolean update(Student student) {
        SqlSession sqlSession = MyBatisUtil.getSqlSession();
        StudentMapper studentMapper = sqlSession.getMapper(StudentMapper.class);
        int row = studentMapper.update(student);
        Boolean flag;
        if(row>0){
            flag = true;
        }else {
            flag = false;
        }
        sqlSession.commit();
        return flag;
    }
}
